home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_kdelibs.idb / usr / freeware / kde / include / ksimpleconfig.h.z / ksimpleconfig.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  4.1 KB  |  148 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.  
  9.     This library is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.     Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public License
  15.     along with this library; see the file COPYING.LIB.  If not, write to
  16.     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.     Boston, MA 02111-1307, USA.
  18. */
  19. // $Id: ksimpleconfig.h,v 1.6 1998/01/18 14:39:02 kulow Exp $
  20. //
  21. // $Log: ksimpleconfig.h,v $
  22. // Revision 1.6  1998/01/18 14:39:02  kulow
  23. // reverted the changes, Jacek commited.
  24. // Only the RCS comments were affected, but to keep them consistent, I
  25. // thought, it's better to revert them.
  26. // I checked twice, that only comments are affected ;)
  27. //
  28. // Revision 1.4  1998/01/15 13:22:31  kalle
  29. // Read-only mode for KSimpleConfig
  30. //
  31. // Revision 1.3  1997/10/16 11:15:02  torben
  32. // Kalle: Copyright headers
  33. // kdoctoolbar removed
  34. //
  35. // Revision 1.2  1997/10/08 19:28:53  kalle
  36. // KSimpleConfig implemented
  37. //
  38. // Revision 1.1  1997/10/04 19:51:07  kalle
  39. // new KConfig
  40. //
  41.  
  42. #ifndef _KSIMPLECONFIG_H
  43. #define _KSIMPLECONFIG_H
  44.  
  45. #ifdef HAVE_CONFIG_H
  46. #include <config.h>
  47. #endif
  48.  
  49. #include <kconfigbase.h>
  50.  
  51. /** 
  52. * KDE Configuration entries
  53. *
  54. * This is a trivial implementation of KConfigBase for applications
  55. * that need only one configuration file and no default system.
  56. *
  57. * @author Kalle Dalheimer (kalle@kde.org)
  58. * @version $Id: ksimpleconfig.h,v 1.6 1998/01/18 14:39:02 kulow Exp $
  59. * @see KApplication::getConfig KConfigBase KConfig
  60. * @short KDE Configuration Management class
  61. */
  62. class KSimpleConfig : public KConfigBase
  63. {
  64.   Q_OBJECT 
  65.  
  66.   // copy-construction and assignment are not allowed
  67.   KSimpleConfig( const KSimpleConfig& );
  68.   KSimpleConfig& operator= ( const KSimpleConfig& rConfig );
  69.  
  70. protected:
  71.   /** Open all appropriate configuration files and pass them on to
  72.     * parseOneConfigFile()
  73.     */
  74.   virtual void parseConfigFiles();
  75.  
  76. public:
  77.   /** 
  78.     * Construct a read-write KSimpleConfig object. 
  79.     *
  80.     * @param pfile The file used for saving the config data.
  81.     */
  82.   KSimpleConfig( const char* pFile );
  83.  
  84.   /**
  85.     * Construct a KSimpleConfig object and make it either read-write
  86.     * or read-only.  
  87.     *
  88.     * @param pFile The file uses for saving the config data.
  89.     *        bReadOnly Whether the object should be read-only.
  90.     */
  91.   KSimpleConfig( const char* pFile, bool bReadOnly );
  92.  
  93.   /** 
  94.     * Destructor. 
  95.     *
  96.     * Writes back any dirty configuration entries.
  97.     */
  98.   virtual ~KSimpleConfig();
  99.  
  100.   
  101.   /**
  102.     * Returns true if the object is read-only
  103.     *
  104.     */
  105.   bool isReadOnly() const { return data()->bReadOnly; }
  106.  
  107.   /**
  108.    * Write back the cache.
  109.    *
  110.    */
  111.   virtual void sync();
  112.  
  113.   /** Write back the configuration data.
  114.     */
  115.   bool writeConfigFile( QFile& rFile, bool bGlobal = false );
  116.  
  117.   /**
  118.     * Delete a configuration entry.
  119.     *
  120.     * @param pKey The key of the entry to delete
  121.     * @param bLocalized Whether the localized or the non-localized key should
  122.     *                    be deleted
  123.     * @return The old value of that key.
  124.     */
  125.   const QString deleteEntry( const char* pKey, bool bLocalized );
  126.  
  127.   /**
  128.     * Delete a configuration entry group
  129.     *
  130.     * If the group is not empty and bDeep is false, nothing gets
  131.     * deleted and false is returned.
  132.     * If this group is the current group and it is deleted, the
  133.     * current group is undefined and should be set with setGroup()
  134.     * before the next operation on the configuration object.
  135.     *
  136.     * @param pGroup The name of the group
  137.     * @param bDeep Whether non-empty groups should be completely
  138.     * deleted (including their entries)
  139.     * @return If the group does not exist or is not empty and bDeep is
  140.     * false, deleteGroup returns false.
  141.     */
  142.   bool deleteGroup( const char* pGroup, bool bDeep = true );
  143. };
  144.   
  145.  
  146.  
  147. #endif
  148.